<?php

namespace Wilead\AdminBundle\Filter;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class MessageLogFilterType extends AbstractType {

    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('mobile', 'filter_text', array(
                    'label' => '手机号码'
                ))
                ->add('content', 'filter_text', array(
                    'label' => '内容',
                    'condition_pattern' => \Lexik\Bundle\FormFilterBundle\Filter\FilterOperands::STRING_BOTH
                ))
                ->add('created', 'filter_date_range', array(
                    'label' => '发送时间'
                ))
        ;
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'csrf_protection' => FALSE,
            'validation_groups' => array('filtering')
        ));
    }

    /**
     * @return string
     */
    public function getName() {
        return 'wilead_smsbundle_messagelog_filter';
    }

}
